﻿@{
    ViewBag.Title = "GuidDetail";
}
@section scripts
{   
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>  
    <script src="@Url.Content("~/Scripts/common/gridlayout.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
}
<body>
   <form id="form1" runat="server" method="post" style="height: 100%">   
    @Html.Partial("~/Views/Modular/ToolBarReport.cshtml")           
    <div id = "DivHeader">
        <table style="margin-bottom:4px;">
            <tr>
                <td width ="70px" align="right">销售日期：</td>
                <td width ="310px">
                    @Html.Partial("~/Views/Modular/dxDateRange.cshtml") 
                </td>
                <td width ="70px" align="right">销售类型：</td>
                <td width ="90px">
                    <input id="FType" name="FType" class="mini-combobox" style="width:90px;" showNullItem="false" 
                    onvaluechanged="onSaleTypeChanged" allowInput="false" align="left" value ="0" data ="comType"/>                  
                </td>
           </tr>
        </table>
        <table>
            <tr>
                 <td width ="70px" align="right">门店名称：</td>
                <td width ="200px">
                    @Html.Partial("~/Views/Modular/LookupStockInfo.cshtml")                 
                </td>
                <td width ="70px" align="right">导购员：</td>
                <td width ="150px">
                    @Html.Partial("~/Views/Modular/LookupGuider.cshtml")                 
                </td>
            </tr>
        </table>
       <div id="div_goods">
            <table>
                <tr>
                    <td width ="70px" align="right">商品分类：</td>
                    <td width ="200px">                    
                            @Html.Partial("~/Views/Modular/LookupGoodsClass.cshtml")                            
                    </td>
                    <td width ="70px" align="right">品牌名称：</td>
                    <td width ="200px">
                        @Html.Partial("~/Views/Modular/LookupGoodsBrand.cshtml")                 
                    </td>
               </tr>
            </table>
        </div>
    </div>
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" borderStyle="border:1;"pageSize="15"
            url="../Report/GetBillDetail"
            allowCellSelect="true" allowCellEdit="true" showSummaryRow="false" fitColumns="false" sortMode="client">
            <div property="columns">
                <div field="FBillNo" name="FBillNo" width="110" headerAlign="center">单据编号</div>    
                <div field="FDate" name="FDate" width="140px"  headerAlign="center" dateFormat="yyyy-MM-dd HH:mm:ss">日期</div> 
                <div field="FNumber" name="FNumber" width="90" headerAlign="center">导购员编号</div>    
                <div field="FName" name="FName" width="100px"  headerAlign="center">导购员姓名</div>                 
                <div field="FItemType" name="FItemType" width="90px"  headerAlign="center">销售类型</div> 
                <div field="FItemNumber" name="FItemNumber" width="90px"  headerAlign="center">商品/项目编码</div>                 
                <div field="FItemName" name="FItemName" width="160px"  headerAlign="center">商品/项目名称</div> 
                <div field="FQty" width="80"  headerAlign="center" numberFormat="#,0.00" align="right">数量</div>                
                <div field="FAmount" width="80"  headerAlign="center" numberFormat="#,0.00" align="right">金额</div>
                <div field="FRebateAmt" width="80"  headerAlign="center" numberFormat="#,0.00" align="right">提成金额</div>                
                <div field="FTelephone" name="FTelephone" width="130px"  headerAlign="center">联系电话</div>
            </div>
        </div>  
    </div>
    
    <script type="text/javascript">
        var comType = [{ "id": "0", "text": "所有类型" }, { "id": "1", "text": "商品销售提成" },
               { "id": "2", "text": "会员充值提成" },{ "id": "3", "text": "次卡提成" }]

        mini.parse();
        var form = new mini.Form("form1");
        var grid = mini.get("datagrid1");
        var uID = parent.window.getSystemAppID();
        var hdatatype = getQueryString("datatype");
        var sumFields = "FQty,FRealAmount,FAmount";
        var typeCombo = mini.get("FType");

        function FormShown() {
            var nowDate = new Date();
            mini.getbyName("FDate1").setValue(nowDate);
            mini.getbyName("FDate2").setValue(nowDate);
            onSaleTypeChanged(null);
            search();
        }

        function onSaleTypeChanged(e) {
            var mDataType = typeCombo.getValue();
            if ((mDataType == 0) || (mDataType == 1))
            {
                $("#div_goods").show();
            } else {
                $("#div_goods").hide();
            }
        }

        function search() {
            var cDate1 = mini.getbyName("FDate1").getFormValue();
            var cDate2 = mini.getbyName("FDate2").getFormValue();
            var mType = mini.get("FType").getValue();
            var mStockID = mini.get("FStockID").getValue();
            var mEmpID = mini.get("FGuiderNumber").getValue();
            var BrandID = mini.get("FBrandItemID").getValue();
            var ClassID = mini.get("FClassNumber").getValue();

            var json = "[{";
            json = json + '"mListType":' + '"' + hdatatype + '",';//列表类型
            json = json + '"mSystemAppID":' + '"' + uID + '",';
            json = json + '"mDate1":' + '"' + cDate1 + ' 00:00:00",';
            json = json + '"mDate2":' + '"' + cDate2 + ' 23:59:59",';
            json = json + '"mDataType":' + '"' + mType + '",';
            json = json + '"mEmpID":' + '"' + mEmpID + '",';
            json = json + '"mStockID":' + '"' + mStockID + '",';
            json = json + '"mBrandID":' + '"' + BrandID + '",';
            json = json + '"mClassID":' + '"' + ClassID + '"';
            json = json + "}]";

            grid.load({ mydata: json });

            mExportDataUrl = grid.url;
            mExportDataJson = json;//导出
        }

        function onSelectionChanged(e) {
            var mgrid = e.sender;
            var record = mgrid.getSelected();
            if (record) {
                var mCheckFlag = record.FCheckFlag;
                if (!mCheckFlag) {
                    mini.get("removebill").setEnabled(true);
                }
                else {
                    mini.get("removebill").setEnabled(false);
                }
            }
        }

        function printdata() {
            var url = "../Report/PrintReport";
            mini.open({
                url: url,
                title: "打印", width: 1000, height: 700,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var NoneDisplayCol = [0];
                    iframe.contentWindow.InitalPrint(grid, NoneDisplayCol, parent.window.getSystemCompany() + "导购明细");
                }
            });
        }

    </script>

    </form>
</body>
